package com.itheima.ydd.controller;

import com.itheima.ydd.common.ResultData;

import com.itheima.ydd.dto.SysRoleDto;

import com.itheima.ydd.service.ISysMenuService;
import com.itheima.ydd.service.ISysRoleMenuService;
import com.itheima.ydd.service.ISysRoleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author 陈琰彦
 * @since 2023-3-25
 */
@RestController
@RequestMapping("/sys_role")
public class SysRoleController {
    @Autowired
    private ISysRoleService sysRoleService;
    @Autowired
    private ISysMenuService sysMenuService;
    @Autowired
    private ISysRoleMenuService sysRoleMenuService;

    /**
     * 获取所以角色
     * @return
     */
    @GetMapping("/allData")
    public ResultData getAllData() {
        return sysRoleService.getAllData();
    }

    /**
     * 角色列表-分页
     * @param page
     * @param limit
     * @param name
     * @return
     */
    @GetMapping("/list")
    public ResultData page(Integer page, Integer limit, String name) {
        return sysRoleService.page(page, limit, name);
    }
    /**
     * 角色详情（回显）
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public ResultData rowInfo(String id) {
        return sysRoleService.rowInfo(id);
    }

    /**
     * 角色添加
     * @return
     */
    @PostMapping("/add")
    public ResultData add(@RequestBody SysRoleDto sysRoleDto) {
        return sysRoleService.add(sysRoleDto);
    }

    /**
     * 角色删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public ResultData del(String id) {
        return sysRoleService.del(id);
    }

    /**
     * 角色修改
     * @param sysRoleDto
     * @return
     */
    @PostMapping("/update")
    public ResultData update(@RequestBody SysRoleDto sysRoleDto) {
        return sysRoleService.update(sysRoleDto);

    }

    }

